export default {
	props: {
		value: {
			type: Object | String | Number | Array | Boolean
		},
		formRef: {
			type: String,
			default: 'form'
		},
		disabled: {
			type: Boolean,
			default: false
		}
	},
	data() {
		return {
			data: this.value,
			loading: false,
			visible: false
		};
	},
	created() {
	},
	methods: {
		onSubmit() {
			this.$emit('submit', this.data);
		},
		watchData() {},
		watchValue() {},
		dispatchChangeEvent() {
			setTimeout(() => {
				let ev = document.createEvent('HTMLEvents');
				ev.initEvent('change', true, true);
				this.$el.dispatchEvent(ev);
			});
		}
	},
	watch: {
		async value(n) {
			await this.$nextTick();
			this.data = n;
			this.watchValue();
		},
		data: {
			async handler(n) {
				this.$nextTick();
				this.$emit('input', n);
				this.dispatchChangeEvent();
				await this.watchData();
			},
			deep: true
		}
	}
};
